<?php
/**
 *新闻分类管理
 * @author ljm
 */
namespace App\Http\Controllers\Admin;
use App\Models\NewCat;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class NewCatController extends Controller
{
    /**
     *定义模型
     * @var NewCat
     */
    protected $newCatModel;

    /**
     *初始化模型
     * NewCatController constructor.
     */
    public function __construct()
    {
        $this->newCatModel = new NewCat();
    }

    /**
     *显示列表
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index(){
        return view('admin.newcat.index');
    }

    /**
     *列表数据回显
     */
    public function getlist(){
        $params =[
            'where'=>[['is_delete',1]],
            'field'=>['id','pid','status','title','description','is_delete','psort'],
            'order'=>'created_at',
            'getfield'=>true,
            'getcount'=>false,
        ];
        $res = $this->newCatModel->getlist($params);
        return response()->json(array('code'=>0,'data'=>$res['row']));
    }
}
